A lock is a mechanism for enforcing limits on access to a resource in a multithreaded shared memory programming environment. In a software transactional memory (STM) implementation, a runtime address is assigned a corresponding lock without any analysis of an application's characteristics, which may result in high runtime overheads. For example, in a word-based STM implementation, the mapping from a runtime address to a lock is computed using a tagless hashing technique. A defined procedure or mathematical function (e.g. hash function) may be used to find and assign locks to certain shared memory locations. Because no tags of colliding memory locations are maintained, distinct memory locations may be assigned to the same lock causing conflicts, even though there may be no actual conflicts (by virtue of the memory addresses being distinct). These conflicts may be referred to as false conflicts and can impact execution time by increasing the number of aborts or rollbacks.
When a program using atomic sections is presented to a compiler, it can perform one of two actions. The program may lower atomic sections into calls to an STM library, or it may generate a mapping from shared memory to locks and use a locking discipline while accessing shared memory locations. The latter may be referred to as compile-time lock assignment. Compile-lock assignment may be used to address false conflicts, in addition to changing the STM hash function and increasing the number of locks available to a program.